package br.com.hsp.system.repository;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import br.com.hsp.users.GerenteInstituicao;

public class GerenteInstituicaoRepository {
	
	private EntityManager manager ;
	
	public GerenteInstituicaoRepository ( EntityManager manager ) {
		this.manager = manager ;
	}
	
	public void add(GerenteInstituicao gerenteInstituicao) {
		this.manager.persist(gerenteInstituicao);
	}
	
	public void remove(Long id) {
		GerenteInstituicao gerenteInstituicao = this.procura(id);
		this.manager.remove(gerenteInstituicao);
	}
	
	public GerenteInstituicao atualiza(GerenteInstituicao gerenteInstituicao) {
		return this.manager.merge(gerenteInstituicao);
	}
	
	public GerenteInstituicao procura(Long id) {
		return this.manager.find(GerenteInstituicao.class, id);
	}
	
	public List<GerenteInstituicao> getLista() {
		Query query = this.manager.createQuery("SELECT x from GerenteInstituicao x");
		return query.getResultList();
	}
}
